package tesis.common.security;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;

public final class GrantedAuthorities {

    private GrantedAuthorities() {
    }

    public static List<String> getAuthorities() {
        List<String> authorities = new ArrayList<String>();
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        Collection<GrantedAuthority> gAuthorities = authentication.getAuthorities();
        for (GrantedAuthority g : gAuthorities) {
            authorities.add(g.getAuthority());
        }
        return authorities;
    }
}
